# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Geoffrey Frogeye <geoffrey+aur@frogeye.fr>

pkgname=check-sieve
pkgver=0.8
pkgrel=1
pkgdesc='Syntax checker for Sieve scripts'
arch=('loong64' 'x86_64')
url='https://github.com/dburkart/check-sieve'
license=('MIT')
depends=('gcc-libs')
makedepends=('git')
checkdepends=('python')
_commit='18bb1f9ac8b233ac29f94212f94148b7855af714'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^check-sieve-//'
}

prepare() {
  cd "$pkgname"

  # ensure LDFLAGS are passed to compiler
  sed \
    -i Makefile \
    -e '/\t$(CXX).*/s/$/ $(LDFLAGS)/'
}


build() {
  cd "$pkgname"

  export CFLAGS+=" -ffat-lto-objects"

  make
}

check() {
  cd "$pkgname"

  make test
}

package() {
  cd "$pkgname"

  make INSTALL_PREFIX="$pkgdir/usr" install

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  # fix incorrect permissions on library
  chmod 644 "$pkgdir/usr/lib/libchecksieve.a"
}

